package com.guestbook.hibernate;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.entity.Admin;
import com.guestbook.dao.AdminDao;
@Repository("adminDao")
public class AdminDaoHiberbate extends GenericsDaoHibernate<Admin, Integer>
        implements AdminDao
{

    @Resource
    public void setMySessionFactory(SessionFactory sessionFactory)
    {
        super.setSessionFactory(sessionFactory);
    }

    public Admin checkPass(Admin admin)
    {
        List<Admin> admins = this.getHibernateTemplate().find(
                "from Admin as a where a.username=? and a.password=?",
                admin.getUsername(), admin.getPassword());
        if (!admins.isEmpty())
            return admins.get(0);
        else
            return null;
    }

}
